<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>tab切换</title>
  <script src="./vue-2.4.0.js"></script>
  <style>
    * {
      margin: 0;
      padding: 0;
    }
    #title {
      margin: 50px auto;
      width: 900px;
      height: 50px;
      list-style: none;
    }
    #title > li {
      float: left;
      width: 300px;
      height: 50px;
      text-align: center;
      line-height: 50px;
      background-color: blue;
      font-size: 30px;
    }
    #content {
      list-style: none;
    }
    #content > li {
      margin: 50px auto;
      width: 900px;
      height: 400px;
      text-align: center;
      line-height: 400px;
      font-weight: 500;
      font-size: 50px;
    }
  </style>
</head>
<body>
<div id="app">
  <ul id="title">
    <li :style="titleOne" @click="tit1">标题一</li>
    <li :style="titleTow" @click="tit2">标题二</li>
    <li :style="titleThree" @click="tit3">标题三</li>
  </ul>
  <ul id="content">
    <li :style="contentColor" v-if="1>titleThis">内容一</li>
    <li :style="contentColor" v-else-if="2>titleThis">内容二</li>
    <li :style="contentColor" v-else>内容三</li>
  </ul>
</div>
</body>
<script>
  let vm = new Vue({
    el: '#app',
    data: {
      titleThis: 0,
      titleOne: 'background-color: green;',
      titleTow: 'background-color: blue;',
      titleThree: 'background-color: blue;',
      contentColor: 'background-color: orange;'
    },
    methods: {
      tit1 () {
        this.titleOne = 'background-color: green;';
        this.titleTow = 'background-color: blue;';
        this.titleThree = 'background-color: blue;';
        this.titleThis = 0;
      },
      tit2 () {
        this.titleOne = 'background-color: blue;';
        this.titleTow = 'background-color: green;';
        this.titleThree = 'background-color: blue;';
        this.contentColor = 'background-color: green;'
        this.titleThis = 1;
      },
      tit3 () {
        this.titleOne = 'background-color: blue;';
        this.titleTow = 'background-color: blue;';
        this.titleThree = 'background-color: green;';
        this.contentColor = 'background-color: purple;'
        this.titleThis = 3;
      }
    }
  })
</script>
</html>